<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/stylesite.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/styleleft.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/mystyle.css" />
<script type="text/javascript" src="../js/jquery-1.8.2.min.js"></script>
<style>
    a{color: blue;}
    a:hover{color: #f80c0c;}
</style>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
        <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css" />
	<script src="../js/jquery-1.8.2.min.js" ></script>
	<script src="../js/image.js" type="text/javascript"></script>
         <script src="../js/jsearch.js" type="text/javascript"></script> 

    <script type="text/javascript">
        var xmlHttp;
		function showTopPro(str)
		{
                if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                                document.getElementById('rightcontent_re').value="";
                     		document.getElementById('rightcontent_re').innerHTML=xmlHttp.responseText;
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                         document.getElementById("rightcontent_re").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Report_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?Month="+str;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
		}
   function showOrderDate(str)
   {
                  if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                                document.getElementById('rightcontent_re').value="";
                     		document.getElementById('rightcontent_re').innerHTML=xmlHttp.responseText;
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                         document.getElementById("rightcontent_re").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Report_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?Status";
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
   }
function OrderDetail(str)
{
	 $("#detailorder").fadeIn();
          $("#closedetail").click(function(){                  
                $("#detailorder").fadeOut();
                }); 
         if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                     		document.getElementById('contentdetail').innerHTML=xmlHttp.responseText;
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                         document.getElementById("contentdetail").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Report_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?OrderID_detail="+str;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
       
}	
function DeleteOrder(str)
{
     if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                     		//document.getElementById('contentdetail').innerHTML=xmlHttp.responseText;
                                var rs=xmlHttp.responseText;
                                alert(rs);
                                showOrderDate(str);
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                        // document.getElementById("contentdetail").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Report_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?OrderID_delete="+str;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);    
}
function UpdateOrder(str)
{
     if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                     		document.getElementById('contentdetail').innerHTML=xmlHttp.responseText;
                                var rs=xmlHttp.responseText;
//                                alert(rs);
//                                showOrderDate(str);
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                         document.getElementById("contentdetail").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Report_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?OrderID_update="+str;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);    
               $("#detailorder").fadeIn();
          $("#closedetail").click(function(){                  
                $("#detailorder").fadeOut();
                });  
}
function CapNhatHD(str)
{
    var sd= document.getElementById("shipdate").value;
    var tt=document.getElementById("total").value;
    var sta=document.getElementById("status").value;
    if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
                                var rs=xmlHttp.responseText;
                                alert(rs);
                                 $("#detailorder").fadeOut();
                                showOrderDate(str);
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                       //  document.getElementById("contentdetail").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Report_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?UpdateOD="+str+"&sd="+sd+"&tt="+tt+"&sta="+sta;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);    
}
function Statistics(str)
{
     if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                     		document.getElementById('rightcontent_re').innerHTML=xmlHttp.responseText;
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                         document.getElementById("rightcontent_re").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Report_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?StatisticID="+str;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
}
function quarterlyreport(str)
{
     if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                     		document.getElementById('rightcontent_re').innerHTML=xmlHttp.responseText;
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                         document.getElementById("rightcontent_re").innerHTML='<img src="../Data/ajax-loader.gif"/>';
                    }
                }
                var url='Report_controller.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?quarterlyreportID="+str;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
}
	</script>
    
   
<title>BÁO CÁO THỐNG KÊ</title>
</head>

<body class="pagebody">
	<div id="wrapwebsite" >
             <?php 
            include('../element/header_adm.php');
                                ?>
            <div class="imagestop"></div>
            <div class="wrapmaincontent">
                <div id="maincontent">
                    <?php
                    if(!isset($_SESSION['user'])|| $_SESSION['user'][4]!='admin')
                        {      
                            echo '<p>Bạn không được quyền xem trang này</p>';
                             header ('location:/cfshop/home.php');
                        }
                        else
                        {
                    ?>     
                    <div class="leftcontent_re">
                        <span style="color:#9B004E;font-weight: bold;font-size: 20px;margin-left: 15px;border-bottom:1px dashed #ccc; ">BÁO CÁO - THỐNG KÊ</span>
                            <div class="borderleft-re">
                               <div id="topsp"><a>Top sản phẩm bán chạy nhất</a></div>
                               Thống kê: <select name="topsp" onChange="showTopPro(this.value)">
                                <option value="all">Tất cả</option>
                                <option value="1">Tháng 1</option>
                                <option value="2">Tháng 2</option>
                                <option value="3">Tháng 3</option>
                                <option value="4">Tháng 4</option>
                                <option value="5">Tháng 5</option>
                                <option value="6">Tháng 6</option>
                                <option value="7">Tháng 7</option>
                                <option value="8">Tháng 8</option>
                                <option value="9">Tháng 9</option>
                                <option value="10">Tháng 10</option>
                                <option value="11">Tháng 11</option>
                                <option value="12">Tháng 12</option>
                            </select>
                            </div>
                             <div class="borderleft-re">
                                 <div id="topsp"><a  onclick="showOrderDate()">Đơn đặt hàng</a></div>
                                               
                         </div> 
                         <div class="borderleft-re">
                              <div id="topsp"><a href="#">Sản Phẩm- Doanh Thu</a></div>
                                    <table>                                            
                                              <tr>
                                                  <td>Chọn tháng: </td>
                                                  <td>
                                                      <select name="thangDoanhThu" style="width:157px;" onchange="Statistics(this.value)">
                                                    <option value="all">Cả năm</option>
                                                    <option value="1">Tháng 1</option>
                                                    <option value="2">Tháng 2</option>
                                                    <option value="3">Tháng 3</option>
                                                    <option value="4">Tháng 4</option>
                                                    <option value="5">Tháng 5</option>
                                                    <option value="6">Tháng 6</option>
                                                    <option value="7">Tháng 7</option>
                                                    <option value="8">Tháng 8</option>
                                                    <option value="9">Tháng 9</option>
                                                    <option value="10">Tháng 10</option>
                                                    <option value="11">Tháng 11</option>
                                                    <option value="12">Tháng 12</option>
                                                </select>
                                                  </td>
                                              </tr>
                                               <tr>
                                                  <td>Chọn quý: </td>
                                                  <td>
                                                      <select name="QuyDoanhThu" style="width:157px;" onchange="quarterlyreport(this.value) 
">
                                                    <option value="1">Quý 1</option>
                                                    <option value="2">Quý 2</option>
                                                    <option value="3">Quý 3</option>
                                                    <option value="4">Quý 4</option>
                                                  </select>
                                                  </td>
                                              </tr>
                                          </table>             
                         </div> 
                    </div>
                    <div class="rightcontent_re" id="rightcontent_re">
                        <!-- Top san pham ban chay -->
                        <table align="center" class="table-re">
                        <tr align="center" >
                            <td colspan="7" >THỐNG KÊ TOP SẢN PHẨM BÁN CHẠY NHẤT</td>
                        </tr>
                        <tr>
                            <th>STT</th>
                            <th>Tên SP</th>
                            <th>Mã SP</th>
                            <th>Giá bán</th>
                            <th>Hình ảnh</th>
                            <th>thuộc Danh mục</th>
                            <th>Tổng số lượng bán</th>
                        </tr>
                        <?php 
                                            include 'Report_model.php';
                                            $arr=  getTopProduct();
                                            $dem=0;
                                            foreach ($arr as $top) {  
                                                $dem+=1;
                                           ?>
                        
                        <tr align="center">
                        	<td><?php echo $dem; ?></td>
                                <td><?php echo $top[2]; ?></td>
                                <td><?php echo $top[1]; ?></td>
                                <td><?php echo $top[4]; ?></td>
                                <td><img width="70px" height="70px" src="<?php echo $top[3]; ?>" > </td>
                                <td><?php echo $top[5]; ?></td>
                                 <td><?php echo $top[0]; ?></td>
                        </tr>
                       
                        <?php
                                                }
                        
                        ?>
                         </table>
                    </div>
             <?php 
                        }
                  ?>
                </div>
                
            <div id="detailorder">
                <div id="borderdetail">
                     <div id="closedetail"></div>       
                    <div id="contentdetail" >

                   </div>
                </div>
             </div>
                
           </div>
          
        </div>
    
</body>
       
</html>
